<?php
// 应用公共文件

function showJson($code = '200', $msg = '', $data = [], $httpStatus = 200): \think\response\Json
{
    $status = [
        'code' => $code,
        'message' => $msg,
    ];
    $result =  array_merge($status, $data);
    return json($result, $httpStatus);
}

/**
 * 计算延迟时间
 *
 * @param string $date 年-月-日 时:分
 * @return int
 */
function delayTime(string $date): int
{
    $second = strtotime($date) - strtotime(date("Y-m-d H:i"));

    $delay = 0;
    if ($second > 0) {
        $delay = $second;
    }
    return $delay;
}